package examples 
{
	import entities.PlatformBoy;
	import entities.PlatformGunner;
	
	import flash.display.*;
	import flash.events.*;
	import flash.geom.*;
	import flash.net.*;
	import flash.utils.*;
	
	import pure.debug.*;
	import pure.engine.*;
	import pure.engine.monitor.*;
	import pure.engine.renderer.*;
	import pure.engine.status.*;
	import pure.engine.status.motion.*;
	import pure.engine.system.*;
	import pure.engine.world.WorldManager;
	import pure.ui.Button;
	import pure.utils.DesU;
	
	import sections.SectionData;
	
	/**
	 * @author pure
	 */
[SWF(width="960",height="580",backgroundColor="0xeeeeee",frameRate="60")]
public class PlatformDemo extends Sprite 
{
	public function PlatformDemo() 
	{
		

		stage.quality = StageQuality.BEST;
		stage.align = 'TL';
		stage.scaleMode = 'noScale';
		
		// 启动
		Despair.startup(this);
		
		var stats:StatsKai = new StatsKai();
		addChild(stats);
		stats.x = 860;
		
		// 注册片段
		Despair.registerSections(SectionData.data);

		// 注册实体
		Despair.registerEntities(PlatformBoy, PlatformGunner);

		// 注册世界Body
		Despair.registerWorldBody('p','id');
		Despair.registerWorldBody('b','id');
		
		// 加入世界Content
		Despair.setWorldData('p',new PlatformWorldB());
		
		// 监视器
		camera = Despair.createMonitor(760, 480,'p',true,true,0.9,0xff0000);
		camera.moveInWorld(0, 600);
		camera.y = 60;
		addChild(camera);
		camera.follow('PlatformBoy');
		
		// 'RESET'按钮
		var button:Button = new Button(50, 20, new Point(60, 25));
		button.label = 'RESET';
		button.setObserverClick(function():void {
			//Despair.setWorld(new Box2DWorld());
			Despair.setWorldData('p',new PlatformWorldB());
		})
		addChild(button);
		
		// 'MONITOR-2'按钮
		var button2:Button = new Button(150, 20, new Point(80, 25));
		button2.label = 'MONITOR-2';
		button2.setObserverClick(_makeMonitor2);
		addChild(button2);
		
	}


	protected function _makeMonitor2():void
	{
		if (_camera2)
		{
			_camera2.destroy();
			removeChild(_camera2);
			_camera2 = null;
		}
		else
		{
			_camera2 = Despair.createMonitor(390, 440,'p',false, true, 0.8);
			_camera2.moveInWorld(0, 600);
			_camera2.x = 380;
			_camera2.y = 70;
			addChild(_camera2);
		}
	}

		
	protected static var _camera2:Monitor;
	protected static var camera:Monitor;	
	
	

}

}
